(* A simple sanity check for the container class. *)

staload "generator.sats"
staload "container.sats"

staload "container.dats"

assume label = int

extern
fun cmp_int(target:int, current:int) : bool

implement cmp_int(target,current) = target = current

local
  var foo : container(int) = new_container()
  viewdef foov = container(int) @ foo
in
  val foop = &foo
  val fool = generator_lock_make{foov}( view@(foo) | (*none*) )
end

implement main () = let
  val (pf | () ) = generator_lock_acquire(fool)
  val () = save_to_container(4,!foop)
  val () = save_to_container(8,!foop)
  val () = save_to_container(12,!foop)
  val got = get_from_container(8,!foop,cmp_int)
  val () = printf("Got %d\n",@(got))
  val () = generator_lock_release( pf | fool)
  in end
